import Cookies from 'js-cookie'

const tokenKey = 'access_token',
  refreshTokenKey = 'refresh_token';

export function getToken(){
  return Cookies.get(tokenKey)
}
export function setToken(token,expiresTime){
  let options = { path: "/"}
  if (expiresTime) options.expires = expiresTime/ 24;
  return Cookies.set(tokenKey, token,options)
}
export function removeToken(){
  Cookies.remove(tokenKey)
}
export function getRefreshToken(){
  return Cookies.get(refreshTokenKey)
}
export function setRefreshToken(token,expiresTime){
  let options = { path: "/"}
  if (expiresTime) options.expires = expiresTime/ 24;
  return Cookies.set(refreshTokenKey, token,options)
}
export function removeRefreshToken(){
  Cookies.remove(refreshTokenKey)
}
export function setLogin(token,refresh,expires){
  this.setToken(token , expires)
  this.setRefreshToken(refresh , expires)
}
export function removeLogin(){
  this.removeToken();
  this.removeRefreshToken()
}

